import React, {Component} from 'react';
import {StyleSheet, Text, View, Image, ScrollView, ImageBackground, Alert} from 'react-native';
import {Button, WhiteSpace, WingBlank, Flex, Toast} from '@ant-design/react-native';
import {getParkingOrderSingleInfo, ownerPayment} from '~/api/parking';
class PaySuccess extends Component {
    static navigationOptions = {
        title: '定金支付成功',
        headerTransparent: true,
    };

    constructor(props) {
        //调用基类的所有的初始化方法
        super(props);

        // 设置当前组件的属性
        this.state = {
            orderid: this.props.navigation.getParam('orderid'),
            PayMode: 0, //1全款 2零首付
            parkid: 0,
        };
        getParkingOrderSingleInfo(this.state.orderid).then((r) => {
            if (r.code === 0) {
                this.setState({
                    DepositPirce: r.data.DepositPirce,
                    PayMode: r.data.PayMode,
                    parkid: r.data.ParkingDataID,
                });
            } else {
                Toast.info(r.msg, 1);
            }
        });
    }

    render() {
        const onpress = () => {
            if (this.state.PayMode == 1) {
                this.props.navigation.replace('PayMoney', {orderid: this.state.orderid, parkid: this.state.parkid});
            } else if (this.state.PayMode == 2) {
                this.props.navigation.replace('PayLoan', {params: this.state.parkid, orderid: this.state.orderid});
            }
        };
        const cancel = () => {
            this.props.navigation.replace('MyOrder');
        };

        return (
            <View style={styles.container}>
                <ImageBackground style={styles.image} source={require('~/assets/login/buttom12x.png')} />
                <View
                    style={{
                        flex: 1,
                        justifyContent: 'center',
                        alignItems: 'center',
                    }}>
                    <View style={styles.view}>
                        <View justify={'center'}>
                            <Text style={styles.fltext}>定金支付成功</Text>
                            <Flex justify={'center'}>
                                <Image style={{width: 95, height: 87, marginTop: 44}} source={require('~/assets/public/buysuccess2x.png')} />
                            </Flex>
                            <Flex direction={'row'} justify={'around'}>
                                <Flex justify={'center'} style={styles.button} onPress={cancel}>
                                    <Text style={styles.butext}>{this.state.PayMode == 2 ? '稍后选择' : '稍后付款'}</Text>
                                </Flex>
                                <Flex justify={'center'} onPress={onpress} style={styles.button1}>
                                    <Text style={styles.butext}>{this.state.PayMode == 2 ? '立选金融产品' : '立即支付尾款'}</Text>
                                </Flex>
                            </Flex>
                        </View>
                    </View>
                </View>
            </View>
        );
    }
}

export default PaySuccess;
const styles = StyleSheet.create({
    container: {
        width: '100%',
        height: '35%',
        flexDirection: 'column',
    },
    image: {
        flex: 1,
        height: 220,
        resizeMode: 'repeat',
        justifyContent: 'center',
    },
    view: {
        width: 277,
        height: 400,
        marginTop: 280,
        borderRadius: 15,
        backgroundColor: 'white',
    },
    imagessuccess: {
        marginTop: 37,
        width: 103,
        height: 107,
    },
    fltext: {
        color: '#333333',
        fontSize: 18,
        marginTop: 20,
        textAlign: 'center',
    },
    fltext2: {
        color: '#999999',
        paddingLeft: 10,
        paddingRight: 10,
        textAlign: 'center',
        fontSize: 13,
        marginTop: 21,
    },
    button: {
        width: 105,
        height: 35,
        borderRadius: 2.5,
        marginTop: 23,
        fontSize: 14,
        backgroundColor: '#F2BC38',
    },
    button1: {
        width: 105,
        height: 35,
        borderRadius: 2.5,
        marginTop: 23,
        marginLeft: 8,
        fontSize: 14,
        backgroundColor: '#EC4F46',
    },
    butext: {
        color: '#FFFFFF',
    },
    item: {
        width: '100%',
    },
    lowername: {
        fontSize: 15,
        color: '#333333',
        fontWeight: 'bold',
    },
    itemtextview: {
        width: '75%',
        flexDirection: 'column',
        marginLeft: 17,
        paddingLeft: 10,
    },

    text: {
        fontSize: 12,
        color: '#666666',
        marginTop: 9,
    },
    biaoqian: {
        marginTop: 14,
        width: 40,
        height: 20,
        fontSize: 10,
        borderRadius: 2,
        textAlign: 'center',
        paddingTop: 2,
        backgroundColor: '#EB5A31',
        color: '#FFFFFF',
    },
    money: {
        marginTop: 14,
        fontSize: 14,
        marginLeft: 12,
        color: '#EB5A31',
    },
    tjtext: {
        fontSize: 8,
    },
});
